<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enginid" class="layui-input enginid" onclick="openPage('../public/choose_engin_page_jun.php?dom=enginid&page=engin_junyan','80%','80%')">
                            <div class="choose_div" id="enginid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin_page_jun.php?dom=enginid&page=engin_junyan','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">合同名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="shi_name" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>建设性质</label>
                        <div class="layui-input-block">
                            <select id="buture" name="buture" lay-filter="buture" ></select>
                            <p class="error" id="buture_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">建设单位</label>
                        <div class="layui-input-block">
                            <input type="text" id="shi_faer" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">施工单位</label>
                        <div class="layui-input-block">
                            <input type="text" id="shi_chenger" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">设计单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="she_unit" id="she_unit" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">监理单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="li_unit" id="li_unit" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>开工日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="actualdt" id="actualdt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>竣工日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="filishdt" id="filishdt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>验收结论</label>
                        <div class="layui-input-block">
                            <select id="yanjie" name="yanjie" lay-filter="yanjie" ></select>
                            <p class="error" id="yanjie_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>验收日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="yandt" id="yandt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">整改问题</label>
                        <div class="layui-input-block">
                            <textarea id="expwen" name="expwen" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">验收意见</label>
                        <div class="layui-input-block">
                            <textarea id="expjian" name="expjian" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联单据</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>



    </div>
</form>
<script>
    $("#commentForm").validate({
        rules: {
            actualdt: {required: true},
            filishdt: {required: true},
            yandt: {required: true},
        },
        messages:{
            actualdt: {required: "请选择"},
            filishdt: {required: "请选择"},
            yandt: {required: "请选择"},
        }
    });







    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_add_engin_junyan}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                $("#number").val(data.number);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                }

                var buture_str = '<option value="">请选择</option>';
                var buture = res.data.buture;
                for (var key in buture){
                    buture_str += '<option value="'+buture[key]+'">'+buture[key]+'</option>';
                }
                $("#buture").html(buture_str);


                var yanjie_str = '<option value="">请选择</option>';
                var yanjie = res.data.yanjie;
                for (var key in yanjie){
                    yanjie_str += '<option value="'+yanjie[key]+'">'+yanjie[key]+'</option>';
                }
                $("#yanjie").html(yanjie_str);



                public_upload_file_load('upload_files');
                render_date();
                render_from();
                initParseMoney();
            }
        });


        form.on('select(buture)', function(data){
            if(data.value == ''){
                $('#buture_error').show().text('请选择');
                $('#buture_error').parent().find('input').addClass('select_error');
            }else{
                $('#buture_error').hide();
                $('#buture_error').parent().find('input').removeClass('select_error');
            }
        });
        form.on('select(yanjie)', function(data){
            if(data.value == ''){
                $('#yanjie_error').show().text('请选择');
                $('#yanjie_error').parent().find('input').addClass('select_error');
            }else{
                $('#yanjie_error').hide();
                $('#yanjie_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');
            data.field.enginid = get_choose_val('enginid');
            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();
                data.field.enginid = get_choose_val('enginid');
                formValid('enginid');
                if(data.field.enginid == undefined || !data.field.enginid){
                    validRes = false;
                }

                if(data.field.buture == ''){
                    $('#buture_error').show().text('请选择');
                    $('#buture_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#buture_error').hide();
                    $('#buture_error').parent().find('input').removeClass('select_error');
                }

                if(data.field.yanjie == ''){
                    $('#yanjie_error').show().text('请选择');
                    $('#yanjie_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#yanjie_error').hide();
                    $('#yanjie_error').parent().find('input').removeClass('select_error');
                }

                if(!validRes){return false;}
            }







            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);
            public_flow_submit(data.field, ask_flowdata_add_engin_junyan, ask_flowdata_edit_engin_junyan, $(this).attr('but'));

            return false;
        });

    });





    function choose_enginid_delete() {
        $("#shi_name").val('');
        $("#shi_faer").val('');
        $("#shi_chenger").val('');
    }







</script>
</body>
</html>
